package com.dc.gameserver.extComponents.utilsKit.util;

import com.dc.gameserver.baseConfig.Config;
import com.dc.gameserver.serverCore.controller.AbstractController.IController;
import org.apache.log4j.xml.DOMConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

//import Server.BaseConfig.Iconfig.ServerConfig;
//import Server.BaseConfig.NServerConfig;
//import Server.ExtComponents.utilsKit.util.PackageUtils;
//import Server.ExtComponents.utilsKit.util.ProperTiesUtil;
//import Server.ServerCore.Controller.AbstractController.IController;
//import org.apache.log4j.xml.DOMConfigurator;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.util.Properties;
//
////package Server.ExtComponents.utilsKit;//package Server.ExtComponents.utilsKit;
////
////import Server.BaseConfig.NServerConfig;
////import Server.BaseConfig.ServerConfig;
////import org.apache.log4j.xml.DOMConfigurator;
////import org.slf4j.Logger;
////import org.slf4j.LoggerFactory;
////
////import java.util.Properties;
////
//////
//////
//////import Server.ExtComponents.BaseConfig.ServerConfig;
//////import Server.ExtComponents.NettyEngine3.config.NServerConfig;
//////import Server.ServerCore.Service.Logic.IController;
//////import org.apache.log4j.xml.DOMConfigurator;
//////import org.slf4j.Logger;
//////import org.slf4j.LoggerFactory;
//////
//////import java.util.Properties;
//////
//////
///////**
////// * @author :陈磊 <br/>
////// * Date: 12-12-9<br/>
////// * Time: 下午9:19<br/>
////// * connectMethod:13638363871@163.com<br/>
////// *  映射游戏数据包和处理逻辑函数
////// *  添加到相应的数组中保存
////// *  1.初始化逻辑处理函数引用对象
////// *  2.注册处理的数据包和处理函数引用对象的映射关系
////// *  3.反射处理加载
////// */
@SuppressWarnings("unchecked")
public class MapperSocketPack{
    private  final Logger LOGGER = LoggerFactory.getLogger(MapperSocketPack.class);
   /****使用数组来存储数据包和处理函数的关系，通过数组下标索引来找到相应的操作处理函数的引用，注意，产生的实例引用时单例，所以是线程安全的**/
    public static final IController[] GAME_CONTROLLERS=new IController[255];//游戏数据包
    public static final IController[] NEGATIVE_GAME_CONTROLLERS=new IController[127];//高频游戏数据包


    /**
     * 注册处理关系
     */
    public void addMapper() throws Exception {
        //通过反射，找到包路径下的class，返回类数组
        String[] ControllerClassNames = PackageUtils.findClassesInPackage("com/dc/gameserver/proto/gameserverprotoVo");
        Properties properties= ProperTiesUtil.getProPertis("");

         //game pack
        for(String className : ControllerClassNames) {
                IController iController = (IController) Class.forName(className).newInstance();
                int i=Integer.parseInt(properties.getProperty(className.substring(className.lastIndexOf('.') + 1)));
        }
        properties.clear();
    }

    public static void main(String[] args) throws Exception{
        DOMConfigurator.configure(Config.DEFAULT_VALUE.FILE_PATH.LOG4J);
        MapperSocketPack mapperSocketPack=new MapperSocketPack();
        mapperSocketPack.addMapper();
    }

}
